/**
 * 角色的接口封装
 */
import request from '@/utils/request'
/**
 * 获取角色列表
 */
export const getRoleList = () => request({
  method: 'get',
  url: '/roles'
}).then(res => res.data)
/**
 * 添加角色
 */
export const addRole = ({ roleName, roleDesc }) => request({
  method: 'post',
  url: '/roles',
  data: {
    roleName,
    roleDesc
  }
}).then(res => res.data)
/**
 * 根据id查询角色
 */
export const getRoleListById = (id) => request({
  method: 'get',
  url: `/roles/${id}`
}).then(res => res.data)
/**
 * 编辑提交角色
 */
export const editRole = (id, { roleName, roleDesc }) => request({
  method: 'put',
  url: `/roles/${id}`,
  data: {
    roleName,
    roleDesc
  }
}).then(res => res.data)
/**
 * 删除角色
 */
export const deleteRole = (id) => request({
  method: 'delete',
  url: `/roles/${id}`
}).then(res => res.data)
/**
 * 更新用户权限
 */
export const updateRightsByRoleId = (roleId, rids) => request({
  method: 'post',
  url: `/roles/${roleId}/rights`,
  data: {
    rids
  }
}).then(res => res.data)
/**
 * 删除角色指定权限
 */
export const deleteRights = (roleId, rightsId) => request({
  method: 'delete',
  url: `/roles/${roleId}/rights/${rightsId}`
}).then(res => res.data)
